﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="urn:mvmmapper:mappingfile"
           elementFormDefault="qualified"
           xmlns="urn:mvmmapper:mappingfile"
           xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="ViewModelMapping"
              type="viewModelMappingType"  />

  <xs:complexType name="viewModelMappingType">
    <xs:sequence>
      <xs:element name="ViewModelClass"
                  type="viewModelClass"
                  minOccurs="1"
                  maxOccurs="1"/>
      <xs:element name="ViewModelProviderClass"
                  type="viewModelProviderClass"
                  minOccurs="0"
                  maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="viewModelClass">
    <xs:sequence>
      <xs:element name="BaseClass"
                  type="baseClass"
                  minOccurs="0"
                  maxOccurs="1"/>
      <xs:element name="Properties"
                  type="properties"
                  minOccurs="0"
                  maxOccurs="1"/>
      <xs:element name="Commands"
                  type="commands"
                  minOccurs="0"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="namespace"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="modelClass"
                  type="xs:string"
                  use="optional"/>
    <xs:attribute name="implementIEditableObject"
                  type="xs:boolean"
                  use="optional"/>
    <xs:attribute name="commandClass"
                  type="xs:string"
                  use="optional" />
    <xs:attribute name="collectionClassName"
                  type="xs:string"
                  use="optional"/>
  </xs:complexType>



  <xs:complexType name="baseClass">
    <xs:sequence>
      <xs:element name="GenericParameters"
                  type="genericParameters"
                  minOccurs="0"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="implementsINotifyPropertyChanged"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="genericParameters">
    <xs:sequence>
      <xs:element name="GenericParameter"
                  type="genericParameter"
                  minOccurs="1"
                  maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="genericParameter">
    <xs:annotation>
      <xs:documentation>Generic Parameter</xs:documentation>
    </xs:annotation>
  </xs:complexType>
  <xs:complexType name="properties">
    <xs:sequence>
      <xs:element name="Property"
                  type="property"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="property">
    <xs:sequence>
      <xs:element name="ModelMapping"
                  type="modelMapping"
                  minOccurs="0"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="type"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="isViewModel"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="modelMapping">
    <xs:attribute name="propertyPath"
                  type="xs:string"
                  use="optional"/>
    <xs:attribute name="isCustom"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="commands">
    <xs:sequence>
      <xs:element name="Command"
                  type="command"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="command">
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
  </xs:complexType>

  <xs:complexType name ="viewModelProviderClass">
    <xs:sequence>
      <xs:element name="Methods"
                  type="methods"
                  minOccurs="0"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="namespace"
                  type ="xs:string"
                  use="required" />
  </xs:complexType>
  <xs:complexType name ="methods">
    <xs:sequence>
      <xs:element name="Method"
                  type="method"
                  minOccurs="0"
                  maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="method">
    <xs:sequence>
      <xs:element name="Result"
                  type="result"
                  minOccurs="1"
                  maxOccurs="1"/>
      <xs:element name="Parameter"
                  type="parameter"
                  minOccurs="0"
                  maxOccurs="1"/>
      <xs:element name="WrappedMethod"
                  type="wrappedMethod"
                  minOccurs="1"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="generateCommand"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="result">
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="type"
                  type ="xs:string"
                  use="required" />
    <xs:attribute name="isViewModel"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="parameter">
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="type"
                  type ="xs:string"
                  use="required" />
    <xs:attribute name="isViewModel"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="wrappedMethod">
    <xs:sequence>
      <xs:element name="Parameter"
                  type="wrappedMethodParameter"
                  minOccurs="0"
                  maxOccurs="1"/>
      <xs:element name="Result"
                  type ="wrappedMethodResult"
                  minOccurs="1"
                  maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="providerName"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="providerNamespace"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="isStatic"
                  type="xs:boolean"
                  use="optional"/>
  </xs:complexType>
  <xs:complexType name="wrappedMethodParameter">
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="type"
                  type ="xs:string"
                  use="required" />
  </xs:complexType>
  <xs:complexType name="wrappedMethodResult">
    <xs:choice minOccurs="1"
               maxOccurs="1">
      <xs:element name="Asynchronous"
                  type="asynchronous"/>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="asynchronous">
    <xs:attribute name="methodCompletedEventName"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="eventArgsType"
                  type ="xs:string"
                  use="required" />
  </xs:complexType>
  <xs:complexType name="methodCompleted">
    <xs:attribute name="name"
                  type="xs:string"
                  use="required"/>
    <xs:attribute name="type"
                  type ="xs:string"
                  use="required" />
  </xs:complexType>
</xs:schema>
